home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 22
/
freelog 22.iso
/
Prog
/
Djgpp
/
GPC2952B.ZIP
/
info
/
gpc.i13
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
Macintosh to JP
NeXTSTEP
RISC OS/Acorn
Shift JIS
UTF-8
Wrap
GNU Info File
|
2001-02-09
|
50.2 KB
|
2,623 lines
This is gpc.info, produced by makeinfo version 4.0 from gpc.texi.
INFO-DIR-SECTION GNU programming tools
START-INFO-DIR-ENTRY
* GPC: (gpc). The GNU Pascal Compiler.
END-INFO-DIR-ENTRY
INFO-DIR-SECTION Individual utilities
START-INFO-DIR-ENTRY
* GPC: (gpc)Invoking GPC. The GNU Pascal Compiler.
END-INFO-DIR-ENTRY
This file documents the GNU Pascal Compiler.
Copyright (C) 1988, 1996-2001 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the sections entitled "GNU General Public License", "The GNU
Project", "The GNU Manifesto" and "Funding for Free Software" are
included exactly as in the original, and provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the sections entitled "GNU General Public
License", "The GNU Project", "The GNU Manifesto" and "Funding for Free
Software" and this permission notice, may be included in translations
approved by the Free Software Foundation instead of in the original
English.
File: gpc.info, Node: absolute, Next: abstract, Prev: Abs, Up: Reference
absolute
========
Synopsis
--------
var
VARIABLE NAME: DATA TYPE absolute VARIABLE REFERENCE;
or
var
VARIABLE NAME: DATA TYPE absolute INTEGER EXPRESSION;
Description
-----------
The first meaning of the `absolute' directive allows to put a
variable to the address of another one and thus provides a type-casting
mechanism.
In most cases, VARIABLE REFERENCE will be just a variable name, but
GPC also allows arbitrary pointer expressions here. If VARIABLE
REFERENCE has neither a constant address nor is a variable parameter,
GPC prints a warning. This warning is suppressed in "extended syntax"
mode which is switched on by the `--extended-syntax' option or the
`{$X+}' compiler directive.
GPC also allows explicit type casts. Variant records (as defined in
ISO-7185 Standard Pascal), however, have no _guaranteed_ overlaying and
are therefore _not_ suitable for type casts.
The second meaning of `absolute' places a variable at a specified
address. This is useful on machines without virtual memory addressing
for doing certain low-level operations, but should be avoided on
systems with memory protection such as Unix-like systems. GPC does not
check whether the specified virtual address makes any sense and does
not provide a built-in mechanism to map it to a real address.
GPC warns about this second use of `absolute' unless "extended
syntax" has been requested.
Conforming to
-------------
`absolute' is a Borland Pascal extension.
Borland Pascal has a slightly different syntax for the second
meaning related to the addressing scheme of Intel x86 processors
working in real mode.
Allowing arbitrary memory references instead of just variable names
in the first meaning of `absolute' is a GNU Pascal extension.
Example
-------
program AbsoluteDemo;
{$X+}
const
IOMem = $f0000000;
var
Mem: array [0 .. High (Cardinal)] of Byte absolute 0;
{ This address has no actual meaning }
MyPort: Byte absolute IOMem + $c030;
{ Beware: Using any of the variables above will crash
your program unless you know exactly what you do!
That's why GPC warns about it without the $X+ directive. }
var
x: Real;
a: array [1 .. SizeOf (Real)] of Byte absolute x;
i: Integer;
b: Byte absolute a [i]; { GNU extension: non-constant memory reference. }
begin
x := 3.14;
{ Look at the internal representation of a real variable. }
for i := 1 to SizeOf (Real) do
Write (a [i] : 4);
WriteLn;
{ The same again, more ugly... }
for i := 1 to SizeOf (Real) do
Write (b : 4);
WriteLn;
{ And yes, there's an even more ugly way to do it... }
for i := 1 to SizeOf (Real) do
Write (Mem [PtrCard (@x) + i - 1] : 4);
WriteLn
end.
See also
--------
*Note record::, *Note Type Casts::.
File: gpc.info, Node: abstract, Next: Addr, Prev: absolute, Up: Reference
abstract
========
Not yet implemented.
Synopsis
--------
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
File: gpc.info, Node: Addr, Next: AlignOf, Prev: abstract, Up: Reference
Addr
====
Synopsis
--------
function Addr (const Foo): Pointer;
Description
-----------
`Addr' returns the address of its argument. It is equivalent to the
address operator and provided for compatibility with Borland Pascal
which in turn implements it for backward-compatibility with Turbo
Pascal.
Conforming to
-------------
`Addr' is a Borland Pascal extension.
Example
-------
program AddrDemo;
var
Foo: ^Integer;
Bar: Integer;
begin
Foo := Addr (Bar); { Let `Foo' point to `Bar'. }
Bar := 17;
Foo^ := 42; { Change the value of `Bar' to 42 }
WriteLn (Bar)
end.
See also
--------
*Note Operators::.
File: gpc.info, Node: AlignOf, Next: all, Prev: Addr, Up: Reference
AlignOf
=======
Synopsis
--------
function AlignOf (var x): Integer;
Description
-----------
Returns the alignment of a type or variable in bytes.
Conforming to
-------------
`AlignOf' is a GNU extension.
Example
-------
program AlignOfDemo;
var
a: Integer;
b: array [1 .. 8] of Char;
begin
WriteLn (AlignOf (a)); { Alignment of `Integer'; usually 4 bytes. }
WriteLn (AlignOf (b)); { Alignment of `Char'; usually 1 byte. }
end.
Although the array is bigger than a single char, it is accessed char
by char, so there usually is no need to align it on a 4 byte boundary
or such. (This may be false on some platforms.)
See also
--------
*Note SizeOf::, *Note BitSizeOf::, *Note TypeOf::.
File: gpc.info, Node: all, Next: and, Prev: AlignOf, Up: Reference
all
===
Synopsis
--------
export foo = all;
Description
-----------
`all' is a predefined export interface for Extended Pascal modules.
You can use it to export all identifiers declared in an interface module
automatically.
Conforming to
-------------
`All' is a GNU extension.
Example
-------
program AllDemo;
import AllInterface in 'allmodule.pas';
begin
Bar (a);
WriteLn (b)
end.
module AllModule interface;
export
AllInterface = all; { Same as `AllInterface = (a, b, Bar);' }
var
a, b: Integer;
procedure Bar (i: Integer);
end.
module AllModule implementation;
procedure Bar (i: Integer);
begin
b := a
end;
to begin do
a := 42;
end.
See also
--------
*Note Modules::.
File: gpc.info, Node: and, Next: and then, Prev: all, Up: Reference
and
===
Synopsis
--------
operator and (operand1, operand2: Boolean) = Result: Boolean;
or
operator and (operand1, operand2: INTEGER TYPE) = Result: INTEGER TYPE;
or
procedure and (var operand1: INTEGER TYPE; operand2: INTEGER TYPE);
Description
-----------
In GNU Pascal, `and' has three built-in meanings:
1. Logical "and" between two `Boolean'-type expressions. The result
of the operation is of `Boolean' type.
By default, `and' acts as a short-circuit operator in GPC: If the
first operand is `False', the second operand is not evaluated
because the result is already known to be `False'. You can change
this to complete evaluation using the `--no-short-circuit'
command-line option or the `{$B+}' compiler directive.
2. Bitwise "and" between two integer-type expressions. The result is
of the common integer type of both expressions.
3. Use as a "procedure": `operand1' is "and"ed bitwise with
`operand2'; the result is stored in `operand1'.
Conforming to
-------------
The logical `and' operator is defined in ISO-7185 Standard Pascal.
According to ISO, you cannot rely on `and' being a short-circuit
operator. On the other hand, GPC's default behaviour does _not_
contradict the ISO standard. (See *Note and_then::.) However, since
it seems to be a de-facto standard among ISO Pascal compilers to
evaluate both operands of `and', GPC switches to `--no-short-circuit'
mode if one of the language dialect options selecting ISO Pascal, for
instance `--extended-pascal', is given. Use `--short-circuit' to
override.
Use of `and' as a bitwise operator for integers is a Borland Pascal
extension.
Use of `and' as a "procedure" is a GNU extension.
Example
-------
program AndDemo;
var
a, b, c: Integer;
begin
if (a = 0) and (b = 0) then { logical `and' }
c := 1
else if a and b = 0 then { bitwise `and' }
c := 2
else
and (c, a) { same as `c := c and a' }
end.
Note the difference between the logical `and' and the bitwise `and':
When `a' is 2 and `b' is 4, then `a and b' is 0. *Beware:* `a and b
= 0' has nothing to do with `(a = 0) and (b = 0)'!
Since bitwise `and' has a higher priority than the `=' operator,
parentheses are needed in `if (a = 0) and (b = 0)' because otherwise `0
and b' would be calculated first, and the remainder would cause a parse
error.
See also
--------
*Note and_then::, *Note and then::, *Note or::, *Note xor::, *Note
Operators::.
File: gpc.info, Node: and then, Next: and_then, Prev: and, Up: Reference
and then
========
Synopsis
--------
{ `and then' is built in. A user-defined operator cannot consist of
two words. }
operator and then (operand1, operand2: Boolean) = Result: Boolean;
Description
-----------
`and then' is an alias for the short-circuit logical operator
`and_then'.
Conforming to
-------------
While `and_then' is defined in ISO-10206 Extended Pascal, `and then'
is a GNU Extension.
Example
-------
program AndThenDemo;
var
p: ^Integer;
begin
New (p);
ReadLn (p^);
if (p <> nil) and then (p^ < 42) then { This is safe. }
WriteLn (p^, ' is less than 42')
end.
See also
--------
*Note and_then::, *Note and::, *Note or else::.
File: gpc.info, Node: and_then, Next: AnsiChar, Prev: and then, Up: Reference
and_then
========
Synopsis
--------
operator and_then (operand1, operand2: Boolean) = Result: Boolean;
Description
-----------
The `and_then' short-circuit logical operator performs the same
operation as the logical operator `and'. But while the ISO standard
does not specify anything about the evaluation of the operands of `and'
- they may be evaluated in any order, or not at all - `and_then' has a
well-defined behaviour: It evaluates the first operand. If the result
is `False', `and_then' returns `False' without evaluating the second
operand. If it is `True', the second operand is evaluated and returned.
Since the behaviour described above is the most efficient way to
implement `and', GPC by default treats `and' and `and_then' exactly the
same. If you want, for some reason, to have both operands of `and'
evaluated completely, you must assign both to temporary variables and
then use `and' - or `and_then', it does not matter.
Conforming to
-------------
`and_then' is an ISO-10206 Extended Pascal extension.
Some people think that the ISO standard requires both operands of
`and' to be evaluated. This is false. What the ISO standard _does_
say is that you cannot rely on a certain order of evaluation of the
operands of `and'; in particular things like the following program can
crash according to ISO Pascal, although they cannot crash when compiled
with GNU Pascal running in default mode.
program AndBug;
var
p: ^Integer;
begin
New (p);
ReadLn (p^);
if (p <> nil) and (p^ < 42) then { This is NOT safe! }
WriteLn ('You''re lucky. But the test could have crashed...')
end.
Example
-------
program And_ThenDemo;
var
p: ^Integer;
begin
New (p);
ReadLn (p^);
if (p <> nil) and_then (p^ < 42) then { This is safe. }
WriteLn (p^, ' is less than 42')
end.
See also
--------
*Note and then::, *Note and::, *Note or_else::.
File: gpc.info, Node: AnsiChar, Next: Append, Prev: and_then, Up: Reference
AnsiChar
========
Synopsis
--------
type
AnsiChar = Char;
Description
-----------
`AnsiChar' is an 8 bit char type. Currently, it is the same as
`Char', but this might change in the future, once `wide chars' (16 bit
chars) will be introduced into GPC. Depending on the platform, `Char'
might be either `AnsiChar' or `WideChar' then.
Conforming to
-------------
`AnsiChar' is a Borland Delphi extension.
Example
-------
program AnsiCharDemo;
var
A: AnsiChar; { There is nothing special with `AnsiChar'. }
B: Char;
begin
A := 'A';
A := B
end.
See also
--------
*Note PAnsiChar::, *Note Char::.
File: gpc.info, Node: Append, Next: ArcTan, Prev: AnsiChar, Up: Reference
Append
======
Synopsis
--------
procedure Append (var F: ANY FILE; [FileName: String;]
[BlockSize: Cardinal]);
Description
-----------
`Append' opens a file for writing. If the file does not exist, it is
created. If it does exist, the file pointer is positioned after the
last element.
Like `Rewrite', `Reset' and `Extend' do, `Append' accepts an
optional second and third parameter for the name of the file in the
filesystem and, for untyped files, the block size of the file. (For
details, see *Note Rewrite::.)
Conforming to
-------------
`Append', including the `BlockSize' parameter, is a Borland Pascal
extension. ISO-10206 Extended Pascal has *Note Extend:: instead. The
`FileName' parameter is a GNU extension.
Example
-------
program AppendDemo;
var
Sample: Text;
begin
Assign (Sample, 'sample.txt');
Rewrite (Sample);
WriteLn (Sample, 'Hello, World!'); { `sample.txt' now has one line }
Close (Sample);
{ ... }
Append (Sample);
WriteLn (Sample, 'Hello again!'); { `sample.txt' now has two lines }
Close (Sample)
end.
See also
--------
*Note Assign::, *Note Reset::, *Note Rewrite::, *Note Update::,
*Note Extend::.
File: gpc.info, Node: ArcTan, Next: Arg, Prev: Append, Up: Reference
ArcTan
======
Synopsis
--------
function ArcTan (x: Real): Real;
or
function ArcTan (z: Complex): Complex;
Description
-----------
`ArcTan' returns the (principal value of the) arcus tangent of the
argument. The result is in the range `-pi / 2 < ArcTan (x) < pi / 2'
for real arguments.
Conforming to
-------------
The function `ArcTan' is defined in ISO-7185 Standard Pascal; its
application to complex values is defined in ISO-10206 Extended Pascal.
Example
-------
program ArcTanDemo;
begin
{ yields 3.14159 as ArcTan (1) = Pi / 4 }
WriteLn (4 * ArcTan (1) : 0 : 5)
end.
See also
--------
*Note Sin::, *Note Cos::, *Note Ln::, *Note Arg::.
File: gpc.info, Node: Arg, Next: array, Prev: ArcTan, Up: Reference
Arg
===
Synopsis
--------
function Arg (z: Complex): Real;
Description
-----------
`Arg' returns the complex "argument", i.e. the angle (in radian) in
the complex plane with respect to the real axis, of its parameter `z'.
The result is in the range of `-Pi < Arg (z) <= Pi'.
Conforming to
-------------
`Arg' is an ISO-10206 Extended Pascal extension.
Example
-------
program ArgDemo;
var
z: Complex;
begin
z := Cmplx (1, 1); { 1 + i }
WriteLn (Arg (z) : 0 : 5) { yields 0.78540, i.e. Pi / 4 }
end.
See also
--------
*Note ArcTan::, *Note Ln::, *Note Polar::.
File: gpc.info, Node: array, Next: asm, Prev: Arg, Up: Reference
array
=====
Synopsis
--------
In type definitions:
array [INDEX TYPE] of ELEMENT TYPE
or
array [INDEX TYPE, ..., INDEX TYPE] of ELEMENT TYPE
In parameter list declarations:
array of ELEMENT TYPE
Description
-----------
The reserved word `array' is used to define an array type.
@@!!!! arrays in parameter lists
Conforming to
-------------
Array types are defined in ISO 7185 Standard Pascal.
Example
-------
program ArrayDemo;
type
IntArray = array [1 .. 20] of Integer;
WeekDayChars = array [(Mon, Tue, Wed, Thu, Fri, Sat, Sun)] of Char;
Foo = array [0 .. 9, 'a' .. 'z', (Baz, Glork1, Fred)] of Real;
TwoDimIntArray = array [1 .. 10] of IntArray;
{ is equivalent to: }
TwoDimIntArray2 = array [1 .. 10, 1 .. 20] of Integer;
procedure PrintChars (F: array of Char);
var
i: Integer;
begin
for i := Low (F) to High (F) do
WriteLn (F [i])
end;
var
Waldo: WeekDayChars;
begin
Waldo := 'HiWorld';
PrintChars (Waldo)
end.
See also
--------
*Note Array Types::, *Note High::, *Note Low::
File: gpc.info, Node: asm, Next: asmname, Prev: array, Up: Reference
asm
===
(Under construction.)
Synopsis
--------
Description
-----------
See
`ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/gpcasm.zip'.
Conforming to
-------------
`asm', as implemented in GPC, is a GNU extension. It is mostly
compatible to GCC's `asm', but not compatible to that of Borland Pascal.
Example
-------
See also
--------
*Note Importing Libraries from Other Languages::, *Note asmname::
File: gpc.info, Node: asmname, Next: Assign, Prev: asm, Up: Reference
asmname
=======
Synopsis
--------
PROCEDURE/FUNCTION HEADER; asmname NAME;
or
VARIABLE DECLARATION; asmname NAME;
Description
-----------
The `asmname' directive declares the external name of a procedure,
function or variable. The external name of the routine is given
explicitly as a case-sensitive string constant. This is useful when
interfacing with libraries written in other languages.
With this extension it is possible to access all external functions,
for example the X11 interface functions, and not only those written in
lowercase.
The idea to use `external' for this purpose (to avoid name space
pollution) conflicts with another Borland extension not yet
implemented: In Borland Pascal, the declaration
procedure Foo; external 'MyLib';
means that the procedure Foo should be imported by name (`Foo') from
a dynamic link library `mylib.dll'.
Conforming to
-------------
`asmname' is a GNU Pascal extension.
Example
-------
program AsmnameDemo;
{ Make two variables aliases of each other by using `asmname'.
This is not good style. If you must have aliases for any reason,
`absolute' declaration may be the lesser evil... }
var
Foo: Integer; asmname 'Foo_Bar';
Bar: Integer; asmname 'Foo_Bar';
{ A function from the C library }
function PutS (Str: CString): Integer; asmname 'puts'; external;
var
Result: Integer;
begin
Result := PutS ('Hello World!');
WriteLn ('puts wrote ', Result, ' characters (including a newline).');
Foo := 42;
WriteLn ('Foo = ', Foo);
Bar := 17;
WriteLn ('Setting Bar to 17.');
WriteLn ('Now, Foo = ', Foo, '!!!')
end.
See also
--------
*Note C::, *Note C_Language::, *Note external::, *Note Importing
Libraries from Other Languages::.
File: gpc.info, Node: Assign, Next: Assigned, Prev: asmname, Up: Reference
Assign
======
(Under contruction.)
Synopsis
--------
procedure Assign (var F: ANY FILE; FileName: String);
Description
-----------
Conforming to
-------------
`Assign' is a Borland Pascal extension.
Example
-------
See also
--------
*Note Reset::, *Note Rewrite::, *Note Update::, *Note Extend::,
*Note Append::.
File: gpc.info, Node: Assigned, Next: attribute, Prev: Assign, Up: Reference
Assigned
========
(Under construction.)
Synopsis
--------
function Assigned (p: Pointer): Boolean;
or
function Assigned (p: PROCEDURAL TYPE): Boolean;
Description
-----------
The `Assigned' function returns `True' if the pointer parameter or
the address of the procedural parameter is not `nil'; it returns
`False' if it is `nil'.
Conforming to
-------------
`Assigned' is a Borland Pascal extension.
Example
-------
program AssignedDemo;
type
PInt = ^Integer;
procedure TellIfOdd (p: PInt);
begin
if Assigned (p) and then Odd (p^) then
WriteLn ('The pointer p points to an odd value.')
end;
var
foo: Integer;
begin
TellIfOdd (nil);
foo := 1;
TellIfOdd (@foo);
foo := 2;
TellIfOdd (@foo)
end.
See also
--------
*Note Null::, *Note nil::, *Note Pointer::.
File: gpc.info, Node: attribute, Next: begin, Prev: Assigned, Up: Reference
attribute
=========
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
`attribute' is a GNU Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: begin, Next: Bind, Prev: attribute, Up: Reference
begin
=====
Synopsis
--------
begin
STATEMENT;
STATEMENT;
...
STATEMENT
end;
Description
-----------
The reserved word `begin' opens a `begin ... end' statement which
joins several STATEMENTS to one compound statement.
Conforming to
-------------
`begin' is defined in ISO 7185 Standard Pascal
Example
-------
program BeginDemo;
begin
if True then
WriteLn ('single statement');
if True then
begin { clamp statement1 ... }
WriteLn ('statement1');
WriteLn ('statement2')
end { ... to statement2 }
end.
See also
--------
*Note begin end Compound Statement::, *Note end::
File: gpc.info, Node: Bind, Next: bindable, Prev: begin, Up: Reference
Bind
====
(Under construction.)
Synopsis
--------
procedure Bind (var F: ANY FILE; B: BindingType);
Description
-----------
Conforming to
-------------
`Bind' is an ISO-10206 Extended Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: bindable, Next: Binding, Prev: Bind, Up: Reference
bindable
========
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
`bindable' is an ISO-10206 Extended Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: Binding, Next: BindingType, Prev: bindable, Up: Reference
Binding
=======
(Under construction.)
Synopsis
--------
function Binding (F: ANY FILE): BindingType;
Description
-----------
Conforming to
-------------
`Binding' is an ISO-10206 Extended Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: BindingType, Next: BitSizeOf, Prev: Binding, Up: Reference
BindingType
===========
(Under construction.)
Synopsis
--------
type
UnixTimeType = LongInt;
BindingType = {@@packed} record
Bound : Boolean;
Force : Boolean; { Can be set to allow binding to
directories or inaccessible files }
Extensions_Valid : Boolean;
Readable : Boolean;
Writable : Boolean;
Executable : Boolean;
Existing : Boolean; { Binding points to an existing file }
Directory : Boolean; { Binding points to an existing
directory; Existing is False then }
Special : Boolean; { Binding points to an existing
special file (device, pipe, socket,
etc.); `Existing' is False then }
SymLink : Boolean; { Binding points to a symbolic link }
AccessTime, { Time of last access }
ModificationTime, { Time of last modification }
ChangeTime : UnixTimeType; { Time of last change }
User, { User ID of owner }
Group, { Group ID of owner }
Mode, { Access permissions, cf. ChMod }
Device, { Device the file is on }
INode : Integer; { Unix INode number }
TextBinary : Boolean; { Open a Text file in binary mode }
Handle : Integer; { Can be set to bind a Pascal file to
a given file handle }
Name : String (Binding_Name_Length)
end;
(@@ Currently, in GPC, BindingType is not actually packed.)
The fields `Bound' and `Name' are required by Extended Pascal.
`Binding_Name_Length' is an implementation-defined constant.
Description
-----------
Conforming to
-------------
`BindingType' is an ISO-10206 Extended Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: BitSizeOf, Next: BlockRead, Prev: BindingType, Up: Reference
BitSizeOf
=========
Synopsis
--------
function BitSizeOf (var x): SizeType;
Description
-----------
Returns the size of a type or variable in bits.
Conforming to
-------------
`BitSizeOf' is a GNU Pascal extension.
Example
-------
program BitSizeOfDemo;
var
a: Integer;
b: array [1 .. 8] of Char;
c: Integer (12);
d: packed record
x: Integer (12);
y: 0 .. 3
end;
begin
WriteLn (BitSizeOf (a)); { Size of an `Integer'; usually 32 bits. }
WriteLn (BitSizeOf (b)); { Size of eight `Char's; usually 64 bits. }
WriteLn (BitSizeOf (c)); { e.g. 16 bits (smallest addressable space). }
WriteLn (BitSizeOf (d)); { e.g. 16 }
WriteLn (BitSizeOf (d.x)); { 12 }
WriteLn (BitSizeOf (d.y)) { 2 }
end.
See also
--------
*Note SizeOf::, *Note AlignOf::, *Note TypeOf::.
File: gpc.info, Node: BlockRead, Next: BlockWrite, Prev: BitSizeOf, Up: Reference
BlockRead
=========
(Under construction.)
Synopsis
--------
procedure BlockRead (var F: File; var Buffer; Blocks: Integer);
or
procedure BlockRead (var F: File; var Buffer; Blocks: Integer;
var BlocksRead: Integer);
Description
-----------
Conforming to
-------------
`BlockRead' is a UCSD Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: BlockWrite, Next: Boolean, Prev: BlockRead, Up: Reference
BlockWrite
==========
(Under construction.)
Synopsis
--------
procedure BlockWrite (var F: File; const Buffer; Blocks: Integer);
or
procedure BlockWrite (var F: File; const Buffer; Blocks: Integer;
var BlocksWritten: Integer);
Description
-----------
Conforming to
-------------
`BlockWrite' is a UCSD Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: Boolean, Next: Break, Prev: BlockWrite, Up: Reference
Boolean
=======
(Under construction.)
Synopsis
--------
type
Boolean = (False, True);
or
type
Boolean (n) { built-in type class }
Description
-----------
Conforming to
-------------
`Boolean' is defined in ISO-7185 Standard Pascal and supported by
all known Pascal variants.
`Boolean (n)' is a GPC extension.
Example
-------
program BooleanDemo;
var
a: Boolean;
begin
a := True;
WriteLn (a)
end.
See also
--------
File: gpc.info, Node: Break, Next: Byte, Prev: Boolean, Up: Reference
Break
=====
Synopsis
--------
Break { simple statement }
Description
-----------
With `Break' you can exit the body of the current loop instantly.
It can only be used within a WHILE, REPEAT or a FOR statement.
Conforming to
-------------
`Break' is a Borland Pascal extension.
Example
-------
program BreakDemo;
var
Foo: Integer;
begin
while True do
begin
repeat
WriteLn ('Enter a number less than 100:');
ReadLn (Foo);
if Foo < 100 then
Break; { Exits repeat loop }
WriteLn (Foo, ' is not exactly less than 100! Try again...')
until False;
if Foo > 50 then
Break; { Exits while loop }
WriteLn ('The number entered was not greater then 50.')
end
end.
See also
--------
*Note Loop Control Statements::, *Note Continue::, *Note Exit::,
*Note Halt::, *Note Return::, *Note goto::.
File: gpc.info, Node: Byte, Next: ByteBool, Prev: Break, Up: Reference
Byte
====
Synopsis
--------
type
Byte { built-in type }
Description
-----------
`Byte' is an unsigned integer type which is one "unit" wide. On
most platforms one unit has 8 bits, therefore the type is named "byte"
and usually has a range of `0..255'. (It is the same as *Note
ByteCard::.)
`Byte' in GNU Pascal is compatible to `unsigned char' in GNU C.
There are lots of other integer types in GPC, see *Note Integer
Types::.
Conforming to
-------------
`Byte' is a Borland Pascal extension. (For something equivalent in
ISO Pascal, see *Note Subrange Types::.)
Example
-------
program ByteDemo;
var
a: Byte;
begin
a := 42;
WriteLn (a)
end.
See also
--------
*Note Integer Types::, *Note Subrange Types::.
File: gpc.info, Node: ByteBool, Next: ByteCard, Prev: Byte, Up: Reference
ByteBool
========
(Under construction.)
Synopsis
--------
type
ByteBool = Boolean (BitSizeOf (Byte));
Description
-----------
Conforming to
-------------
Example
-------
program ByteBoolDemo;
var
a: ByteBool;
begin
Byte (a) := 1;
if a then WriteLn ('Ord (True) = 1')
end.
See also
--------
File: gpc.info, Node: ByteCard, Next: ByteInt, Prev: ByteBool, Up: Reference
ByteCard
========
Synopsis
--------
type
ByteCard = Cardinal (BitSizeOf (Byte));
Description
-----------
`ByteCard' is an unsigned integer type which is one "unit" wide. On
most platforms one unit has 8 bits, therefore the type is prefixed
"byte-" and usually has a range of `0..255'.
`ByteCard' in GNU Pascal is compatible to `unsigned char' in GNU C.
There are lots of other integer types in GPC, see *Note Integer
Types::.
Conforming to
-------------
`ByteCard' is a GNU Pascal extension.
Example
-------
program ByteCardDemo;
var
a: ByteCard;
begin
a := 42;
WriteLn (a)
end.
See also
--------
*Note Integer Types::, *Note Subrange Types::.
File: gpc.info, Node: ByteInt, Next: C, Prev: ByteCard, Up: Reference
ByteInt
=======
Synopsis
--------
type
ByteInt = Integer (BitSizeOf (Byte));
Description
-----------
`ByteInt' is a signed integer type which is one "unit" wide. On
most platforms one unit has 8 bits, therefore the type is prefixed
"byte-" and usually has a range of `-128..127'.
`ByteInt' in GNU Pascal is compatible to `signed char' in GNU C.
There are lots of other integer types in GPC, see *Note Integer
Types::.
Conforming to
-------------
`ByteInt' is a GNU Pascal extension.
`ByteInt' in GNU Pascal corresponds to *Note ShortInt:: in Borland
Pascal.
Example
-------
program ByteIntDemo;
var
a: ByteInt;
begin
a := 42;
WriteLn (a)
end.
See also
--------
*Note Integer Types::, *Note Subrange Types::.
File: gpc.info, Node: C, Next: Card, Prev: ByteInt, Up: Reference
C
=
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
*Note Importing Libraries from Other Languages::, *Note C_Language::
File: gpc.info, Node: Card, Next: Cardinal, Prev: C, Up: Reference
Card
====
Synopsis
--------
function Card (S: ANY SET): Integer;
Description
-----------
The function `Card (S)' returns the number of elements in the set
`S'.
Conforming to
-------------
`Card' is an ISO 10206 Extended Pascal extension.
Example
-------
program CardDemo;
var
Foo: set of 1 .. 100;
begin
Foo := [1, 2, 3, 5, 1, 1, 1, 2, 2, 2, 3, 3, 5, 5]; { four elements }
WriteLn ('foo consists of ', Card (Foo), ' elements')
end.
See also
--------
*Note set::
File: gpc.info, Node: Cardinal, Next: case, Prev: Card, Up: Reference
Cardinal
========
Synopsis
--------
type
Cardinal { built-in type }
or
type
Cardinal (n) { built-in type class }
Description
-----------
`Cardinal' is the "natural" unsigned integer type in GNU Pascal. On
most platforms it is 32 bits wide and thus has a range of
`0..4294967295'. Use it whenever you need a general-purpose unsigned
integer type and don't need to care about compatibility to other Pascal
dialects.
As an extension, GPC allows to use `Cardinal' as a pseudo-schema to
produce types with a specified size in bits; for example
type
Card16 = Cardinal (16);
defines an unsigned integer type with 16 bits. The same mechanism works
for `Integer' and `Word', too.
`Cardinal' in GNU Pascal is compatible to `unsigned int' in GNU C.
There are lots of other integer types in GPC, see *Note Integer
Types::.
Conforming to
-------------
`Cardinal' is not defined in ISO Pascal, but several Pascal
compilers support it as an extension. In Borland Delphi, for instance,
it is an unsigned 16-bit in version 1.0, an unsigned 31-bit integer
from version 2.0 on, and an unsigned 32-bit integer from version 4.0 on.
Example
-------
program CardinalDemo;
var
a: Cardinal;
begin
a := 42;
WriteLn (a)
end.
See also
--------
*Note Integer Types::, *Note Subrange Types::.
File: gpc.info, Node: case, Next: Char, Prev: Cardinal, Up: Reference
case
====
Synopsis
--------
case EXPRESSION of
SELECTOR: STATEMENT;
...
SELECTOR: STATEMENT;
end;
or, with alternative statement sequence:
case EXPRESSION of
SELECTOR: STATEMENT;
...
SELECTOR: STATEMENT;
otherwise { ``else'' instead of ``otherwise'' is allowed }
STATEMENT;
...
STATEMENT;
end;
or, as part of the invariant `record' type definition:
foo = record
FIELD DECLARATIONS
case bar: VARIANT TYPE of
SELECTOR: (FIELD DECLARATIONS);
SELECTOR: (FIELD DECLARATIONS);
...
end;
or, without a variant selector field,
foo = record
FIELD DECLARATIONS
case VARIANT TYPE of
SELECTOR: (FIELD DECLARATIONS);
SELECTOR: (FIELD DECLARATIONS);
...
end;
Description
-----------
`case' opens a case statement. For further description see *Note
case Statement::.
For `case' in a variant record type definition, see *Note Record
Types::.
Conforming to
-------------
The `case' statement is defined in ISO-7185 Standard Pascal and
supported by all known Pascal variants.
According to ISO 7185 Pascal, the selector type must be a named type.
GNU Pascal, UCSD and Borland Pascal also allow a subrange here.
The alternative statement execution with `otherwise' it is an
Extended Pascal extension; with `else' it is a Borland Pascal
extension. In GNU Pascal, both are allowed.
Example
-------
program CaseDemo;
var
Foo: String (10);
Bar: Integer;
begin
WriteLn ('Enter up to ten arbitrary characters:');
ReadLn (Foo);
for Bar := 1 to Length (Foo) do
begin
Write (Foo [bar], ' is ');
case Foo [bar] of
'A' .. 'Z', 'a' .. 'z':
WriteLn ('an English letter');
'0' .. '9':
WriteLn ('a number');
otherwise
WriteLn ('an unrecognized character')
end
end
end.
See also
--------
*Note if Statement::, *Note Record Types::
File: gpc.info, Node: Char, Next: ChDir, Prev: case, Up: Reference
Char
====
(Under construction.)
Synopsis
--------
type
Char { built-in type }
Description
-----------
Conforming to
-------------
`Char' is defined in ISO-7185 Standard Pascal and supported by all
known Pascal variants.
Example
-------
program CharDemo;
var
a: Char;
begin
a := 'x';
WriteLn (a)
end.
See also
--------
File: gpc.info, Node: ChDir, Next: Chr, Prev: Char, Up: Reference
ChDir
=====
Synopsis
--------
procedure ChDir (Directory: String);
Description
-----------
`ChDir' changes the current directory to DIRECTORY, if its argument
is a valid parameter to the related operating system's function.
Otherwise, a runtime error is caused.
Conforming to
-------------
`ChDir' is a Borland Pascal extension.
Example
-------
program ChDirDemo;
var
Foo: String (127);
begin
WriteLn ('Enter directory name to change to:');
ReadLn (Foo);
{$I-} { Don't abort the program on error }
ChDir (Foo);
if IOResult <> 0 then
WriteLn ('Cannot change to directory `', foo, '''.')
else
WriteLn ('Okay.')
end.
See also
--------
*Note MkDir::, *Note RmDir::
File: gpc.info, Node: Chr, Next: C_Language, Prev: ChDir, Up: Reference
Chr
===
Synopsis
--------
function Chr (AsciiCode: Integer): Char;
Description
-----------
`Chr' returns a character whose ASCII code corresponds to the value
given by `AsciiCode'.
Conforming to
-------------
`Chr' is defined in ISO-7185 Standard Pascal and supported by all
known Pascal variants.
Example
-------
program ChrDemo;
var
x: Integer;
begin
for x := 32 to 122 do
Write (Chr (x))
end.
See also
--------
*Note Ord::
File: gpc.info, Node: C_Language, Next: class, Prev: Chr, Up: Reference
C_Language
==========
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
*Note Importing Libraries from Other Languages::, *Note C::
File: gpc.info, Node: class, Next: Close, Prev: C_Language, Up: Reference
class
=====
Not yet implemented.
Synopsis
--------
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
File: gpc.info, Node: Close, Next: Cmplx, Prev: class, Up: Reference
Close
=====
(Under construction.)
Synopsis
--------
procedure Close (var F: ANY FILE);
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
File: gpc.info, Node: Cmplx, Next: Comp, Prev: Close, Up: Reference
Cmplx
=====
Synopsis
--------
function Cmplx (RealPart, ImaginaryPart: Real): Complex;
Description
-----------
`Cmplx' makes a complex number from `RealPart' and `ImaginaryPart'.
Conforming to
-------------
`Cmplx' is an ISO-10206 Extended Pascal extension.
Example
-------
program CmplxDemo;
var
z: Complex;
x, y: Real;
begin
z := Cmplx (x, y) { z := x + iy }
end.
See also
--------
*Note Re::, *Note Im::, *Note Polar::, *Note Arg::
File: gpc.info, Node: Comp, Next: Complex, Prev: Cmplx, Up: Reference
Comp
====
Synopsis
--------
type
Comp = LongInt;
Description
-----------
`Comp' is a signed integer type which is longer than `Integer'. On
most platforms it is 64 bits wide and thus has a range of
`-9223372036854775808..9223372036854775807'.
There are lots of other integer types in GPC, see *Note Integer
Types::.
Conforming to
-------------
`Comp' is a Borland Pascal extension.
In some contexts, Borland Pascal treats `Comp' as a "real" type -
this behaviour is not supported by GPC.
Example
-------
program CompDemo;
var
a: Comp;
begin
a := 42;
WriteLn (a)
end.
See also
--------
*Note Integer Types::, *Note Subrange Types::.
File: gpc.info, Node: Complex, Next: Concat, Prev: Comp, Up: Reference
Complex
=======
(Under construction.)
Synopsis
--------
type
Internal_Complex = record { not visible }
RealPart, ImaginaryPart: Real
end;
Complex = restricted Internal_Complex;
Description
-----------
Conforming to
-------------
`Complex' is an ISO-10206 Extended Pascal extension.
Example
-------
program ComplexDemo;
var
a: Complex;
begin
a := Cmplx (42, 3);
WriteLn (Re (a), ' + ', Im (a), ' i')
end.
See also
--------
File: gpc.info, Node: Concat, Next: Conjugate, Prev: Complex, Up: Reference
Concat
======
(Under construction.)
Synopsis
--------
function Concat (S1, S2: String): String;
or
function Concat (S1, S2, S3: String): String;
or
...
Description
-----------
Conforming to
-------------
`Concat' is a UCSD Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: Conjugate, Next: const, Prev: Concat, Up: Reference
Conjugate
=========
Synopsis
--------
function Conjugate (z: Complex): Complex;
Description
-----------
`Conjugate' computes the complex conjugate of the complex number `z'
Conforming to
-------------
`Conjugate' is an ISO-10206 Extended Pascal extension.
Example
-------
program ConjugateDemo;
var
z: Complex;
begin
z := Cmplx (2, 3); { z is 2 + i * 3 }
WriteLn ('z = ', Re (z) : 0 : 5, ' + i * ', Im (z) : 0 : 5);
z := Conjugate (z); { z conjugate is 2 - i * 3 }
WriteLn ('z conjugate = ', Re (z) : 0 : 5,' + i * ', Im (z) : 0 : 5)
end.
See also
--------
*Note Cmplx::, *Note Re::, *Note Im::, *Note Abs::
File: gpc.info, Node: const, Next: constructor, Prev: Conjugate, Up: Reference
const
=====
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
`const' is defined in ISO-7185 Standard Pascal and supported by all
known Pascal variants.
Example
-------
See also
--------
File: gpc.info, Node: constructor, Next: Continue, Prev: const, Up: Reference
constructor
===========
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
`constructor' is a Borland Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: Continue, Next: Copy, Prev: constructor, Up: Reference
Continue
========
Synopsis
--------
Continue { simple statement }
Description
-----------
`Continue' goes on with loop iteration by jumping to the end of the
current loop body. Note: `Continue' can only stand within a WHILE,
REPEAT or a FOR statement.
Conforming to
-------------
`Continue' is a Borland Pascal extension.
Example
-------
program ContinueDemo;
var
Foo, Bar: Integer;
begin
WriteLn ('Enter three numbers:');
for Bar := 1 to 3 do
begin
ReadLn (Foo);
if Foo < 5 then
Continue;
WriteLn ('Your number was greater then 5.')
end
end.
See also
--------
*Note Loop Control Statements::, *Note Break::, *Note Exit::, *Note
Halt::, *Note Return::, *Note goto::.
File: gpc.info, Node: Copy, Next: Cos, Prev: Continue, Up: Reference
Copy
====
Synopsis
--------
function Copy (S: String; FirstChar, Count: Integer): String;
or
function Copy (S: String; FirstChar: Integer): String;
Description
-----------
`Copy' returns a sub-string of `S' starting with the character at
position FIRSTCHAR. If COUNT is given, such many characters will be
copied into the sub-string. If COUNT is omitted, the sub-string will
will range to the end of S.
If `Count' is too large for the sub-string to fit in S, the result
will be truncated at the end of S. If `FirstChar' exceeds the length of
S, the empty string will be returned. (For a function which does not
truncate but triggers a runtime error instead, see *Note SubStr::.)
Please note that GPC's strings may be longer than 255 characters. If
you want to isolate the second half of a string S starting with the
third character, use `Copy (S, 3)' instead of `Copy (S, 3, 255)'.
Conforming to
-------------
`Copy' is a UCSD Pascal extension. The possibility to omit the third
parameter is a GNU Pascal extension.
Example
-------
program CopyDemo;
var
S: String (42);
begin
S := 'Hello';
WriteLn (Copy (S, 2, 3)); { yields "ell" }
WriteLn (Copy (S, 3)); { yields "llo" }
WriteLn (Copy (S, 4, 7)); { yields "lo" }
WriteLn (Copy (S, 42)) { yields the empty string }
end.
See also
--------
*Note SubStr::, String slice access.
File: gpc.info, Node: Cos, Next: CString, Prev: Copy, Up: Reference
Cos
===
Synopsis
--------
function Cos (x: Real): Real;
or
function Cos (z: Complex): Complex;
Description
-----------
`Cos' returns the cosine of the argument. The result is in the
range `-1 < Cos (x) < 1' for real arguments.
Conforming to
-------------
The function `Cos' is defined in ISO-7185 Standard Pascal; its
application to complex values is defined in ISO-10206 Extended Pascal.
Example
-------
program CosDemo;
begin
WriteLn (Cos (SqRt (2) / 2) : 0 : 5)
{ yields 0.5 since Cos (SqRt (2) / 2) = 0.5 }
end.
See also
--------
*Note ArcTan::, *Note Sin::, *Note Ln::, *Note Arg::.
File: gpc.info, Node: CString, Next: CString2String, Prev: Cos, Up: Reference
CString
=======
(Under construction.)
Synopsis
--------
type
CString = ^Char;
Description
-----------
Conforming to
-------------
Example
-------
program CStringDemo;
var
s: CString;
begin
s := 'Hello, world!';
{$X+}
WriteLn (s)
end.
See also
--------
File: gpc.info, Node: CString2String, Next: CStringCopyString, Prev: CString, Up: Reference
CString2String
==============
(Under construction.)
Synopsis
--------
function CString2String (S: CString): String;
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
File: gpc.info, Node: CStringCopyString, Next: Date, Prev: CString2String, Up: Reference
CStringCopyString
=================
(Under construction.)
Synopsis
--------
function CStringCopyString (Dest: CString; const Source: String): CString;
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
File: gpc.info, Node: Date, Next: Dec, Prev: CStringCopyString, Up: Reference
Date
====
(Under construction.)
Synopsis
--------
function Date (T: TimeStamp): packed array [1 .. DATE LENGTH] of Char;
Description
-----------
Conforming to
-------------
Example
-------
See also
--------
File: gpc.info, Node: Dec, Next: DefineSize, Prev: Date, Up: Reference
Dec
===
Synopsis
--------
For ordinal types:
procedure Dec (var x: ORDINAL TYPE);
or
procedure Dec (var x: ORDINAL TYPE; Amount: Integer);
For pointer types:
procedure Dec (var p: ANY POINTER TYPE);
or
procedure Dec (var p: ANY POINTER TYPE; Amount: Integer);
Description
-----------
For ordinal types, `Dec' decreases the value of `x' by one or by
`amount' if specified.
If the argument `p' is pointing to a specified type (typed pointer),
`Dec' decreases the address of `p' by the size of the type `p' is
pointing to or by `amount' times that size respectively. If `p' is an
untyped pointer (i.e. `p' is of type *Note Pointer::), `p' is decreased
by one, otherwise by `amount' if specified.
Conforming to
-------------
`Dec' is a Borland Pascal extension. The combination of the second
argument with application to pointers is a GNU extension.
Example
-------
program DecDemo;
var
x: Integer;
y: array [1 .. 5] of Integer;
p: ^Integer;
begin
x := 9;
Dec (x, 10); { yields -1 }
{$X+} { Turn on extended systax }
p := @y [5]; { p points to y [5] }
Dec (p, 3) { p points to y [2] }
end.
See also
--------
*Note Inc::, *Note Pred::, *Note Succ::, *Note Pointer Arithmetics::.
File: gpc.info, Node: DefineSize, Next: Delete, Prev: Dec, Up: Reference
DefineSize
==========
(Under construction.)
Synopsis
--------
procedure DefineSize (var F: ANY FILE; NewSize: Integer);
Description
-----------
Conforming to
-------------
`DefineSize' is an ISO-10206 Extended Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: Delete, Next: destructor, Prev: DefineSize, Up: Reference
Delete
======
(Under construction.)
Synopsis
--------
procedure Delete (var S: String; FirstChar, Count: Integer);
Description
-----------
Conforming to
-------------
`Delete' is a UCSD Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: destructor, Next: Dispose, Prev: Delete, Up: Reference
destructor
==========
(Under construction.)
Synopsis
--------
Description
-----------
Conforming to
-------------
`destructor' is a Borland Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: Dispose, Next: div, Prev: destructor, Up: Reference
Dispose
=======
(Under construction.)
Synopsis
--------
Dispose (PointerVar: Pointer);
or
Dispose (PointerVar: Pointer; TAG FIELD VALUES);
or
Dispose (ObjectPointerVar: Pointer; DESTRUCTOR CALL);
Description
-----------
Conforming to
-------------
`Dispose' is defined in ISO-7185 Standard Pascal and supported by
most known Pascal variants, but not by UCSD Pascal. Its use for
objects is a Borland Pascal extension.
Example
-------
See also
--------
File: gpc.info, Node: div, Next: do, Prev: Dispose, Up: Reference
div
===
(Under construction.)
Synopsis
--------
operator div (p, q: Integer) = r: Integer;
Description
-----------
Conforming to
-------------
`div' is defined in ISO-7185 Standard Pascal and supported by all
known Pascal variants.
Example
-------
See also
--------